package com.example.javanewwork.controller;


import com.example.javanewwork.entity.Order;
import com.example.javanewwork.entity.Result;
import com.example.javanewwork.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    @GetMapping("/find")
    public Result findorder(){

        List<Order> orders = orderService.findAll();

        return Result.success(orders);


    }


    @GetMapping("/delete")
    public Result deleteByid(@RequestParam int id){
        orderService.deleteByid(id);
        return Result.success();
    }

    @PostMapping("/modify")
    public Result modify(@RequestBody Order order){
        orderService.modify(order);
        return Result.success();
    }


    @PostMapping("/add")
    public Result add(@RequestBody Order order)
    {
        orderService.add(order);
        return Result.success();
    }



}
